#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/7/23 10:22
# @Author  : Jet
# @Email   : jyan@abot.cn
# @File    : my_datetime.py

import hashlib, time, random

# 测试日期时间
createtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# 2023-07-06 12: 30:23
print(createtime)

# time.struct_time(tm_year=2023, tm_mon=7, tm_mday=6, tm_hour=12, tm_min=30, tm_sec=23, tm_wday=3, tm_yday=187, tm_isdst=0)
print(time.localtime())
print('本月的第 %d 天。' % time.localtime().tm_mday)

# 1688617823.1243799
print(time.time())

# 1688617823
print(int(time.time()))




file_ext_name = '.jpg'

# 用时间戳+随机数，生成md格式的文件名
filemd5 = str(time.time()) + str(random.randint(100, 999))
filemd5 = hashlib.md5(filemd5.encode()).hexdigest()
file_new_name = filemd5 + '' + file_ext_name

print(file_new_name)
